;====================================================================
;
; Ogre3D Wrapper for Blitz3D
;
; Meshes
;
;====================================================================

Function LoadMesh%(filename$, parent% = 0)
	Local path$ 		= getPath(filename)
	Local file$ 		= getFileName(filename)
	Local filesystem$	= "FileSystem"
	Local ext$			= Lower(Right(path, 4))
	
	Select ext
		Case ".zip", ".dat", ".pak"	: filesystem = "Zip" : path = Left(path, Len(path) - 4)
	End Select
	
	If ResourceLocationExists(path) = False
		o_addResourceLocation(path, filesystem, "bo3D", True)
		o_initialiseResourceGroup("bo3D")
		
		AddResourceLocation(path)
	EndIf
	
	ent.TEntity = New TEntity
	ogre_entity_count = ogre_entity_count + 1
	ent\ptr = o_createEntity(ogre3d\ogre_scenemanager, genEntityName(), file, "bo3D")
	ent\typ = ET_ENTITY
	
	Local child% = bb_createChildSceneNode(ogre3d\ogre_rootscenenode, genEntityName())
	o_attachObject(child, ent\ptr)
	
	If parent > 0 Then EntityParent(Handle(ent), parent)
	
	Return Handle(ent)
End Function


Function MeshWidth#(mesh%)
	Local e.TEntity = Object.TEntity(mesh)
	
	Local aab = o_mesh_getBounds(e\ptr)
	Local sze = o_aab_getSize(aab)
	CopyMemory(vector, sze, 12)
	Local x# = PeekFloat(vector, 0)
		Return x
End Function


Function MeshHeight#(mesh%)
	Local e.TEntity = Object.TEntity(mesh)
	
	Local aab = o_mesh_getBounds(e\ptr)
	Local sze = o_aab_getSize(aab)
	CopyMemory(vector, sze, 12)
	Local y# = PeekFloat(vector, 4)
	Return y
End Function


Function MeshDepth#(mesh%)
	Local e.TEntity = Object.TEntity(mesh)
	
	Local aab = o_mesh_getBounds(e\ptr)
	Local sze = o_aab_getSize(aab)
	CopyMemory(vector, sze, 12)
	Local z# = PeekFloat(vector, 8)
	Return z
End Function
;~IDEal Editor Parameters:
;~C#Blitz3D